<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\UserDrug
 *
 * @property int $id
 * @property int $user_id 用户id
 * @property int $enterprise_id 商家id
 * @property string|null $patientName 真实姓名
 * @property int $patientSex 性别 1：男 2：女
 * @property int $patientAge 年龄
 * @property float $patientWeight 体重（kg）
 * @property string|null $patientPhone 手机号
 * @property string|null $patientIdcard 身份证号
 * @property string|null $patientBirthday 出生日期
 * @property int $relationship 关系 0：本人 1：家属 2：亲戚 3：朋友
 * @property string|null $patientAddress 地址
 * @property string|null $pmh 过往病史
 * @property string|null $amh 过敏史
 * @property string|null $fmh 家族病史
 * @property string|null $nurse 妊娠哺乳
 * @property string|null $liver 肝功能
 * @property string|null $renal 肾功能
 * @property int $is_default 是否默认 0：否 1：是
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\UserDrug onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereAmh($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereEnterpriseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereFmh($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereIsDefault($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereLiver($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereNurse($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientAddress($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientAge($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientBirthday($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientIdcard($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientPhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientSex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePatientWeight($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug wherePmh($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereRelationship($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereRenal($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserDrug whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserDrug withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\UserDrug withoutTrashed()
 * @mixin \Eloquent
 */
class UserDrug extends Model
{
    //
    use SoftDeletes;

    public static function getUserDrugInfo($id){
        if(empty($id))
            return null;

        $userDrug = self::whereId($id)->first();
        if($userDrug){
            $userDrug->patientSex_name = $userDrug->patientSex;
            if($userDrug->patientSex == 1)
                $userDrug->patientSex_name = '男';
            elseif($userDrug->patientSex == 2)
                $userDrug->patientSex_name = '女';

            $userDrug->relationship_name = '本人';
            if($userDrug->relationship == 1)
                $userDrug->relationship_name = '家属';
            elseif($userDrug->relationship == 2)
                $userDrug->relationship_name = '亲戚';
            elseif($userDrug->relationship == 3)
                $userDrug->relationship_name = '朋友';

        }

        return $userDrug;
    }
}
